const login_error = {
    SUCCESS: "登录成功",
    TIMEOUT: "验证码已过期",
    CAPTCHA_FAILED: "验证码错误",
    PASSWORD_FAILED: "用户名或密码错误",
    NO_PERMISSIONS: "无权限",
    LOCKED: "已锁定，密码错误次数已达上限"
}

const user_error = {
    NAME_ILLEGAL: "名称非法",
    PASSWORD_ILLEGAL: "密码非法",
    ACCOUNT_ILLEGAL: "名称账号",
    ACCOUNT_EXISTS: "账户已存在",
    ACCOUNT_NOT_EXISTS: "操作的账户不存在",
    PASSWORD_FAILED: "密码错误",
    LOCKED: "已锁定，密码错误次数已达上限",
    NO_PERMISSIONS: "没有权限",
    NEW_PASSWORD_SAME: "新密码与旧密码相同"

}

function getErrorMsg(map, code) {
    let msg = map[code];
    if (!msg) {
        msg = "未知错误"
    }
    return msg;
}

export function getLoginErrorMsg(code) {
    return getErrorMsg(login_error, code);
}

export function getUserError(code) {
    return getErrorMsg(user_error, code)
}